﻿cmake_minimum_required(VERSION 2.8)
project(osgQt)
file(GLOB lib_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
file(GLOB lib_hdrs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} osgQt/*)
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_AUTOMOC ON)  # 让qt5自动为QObject子类生成moc类，即添加信号和槽函数的实现
set(SOURCES_H osgQt/QGraphicsViewAdapter)
#set(OSGQT_QT_VERSION 5)
#set(OSGQT_VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/osgQt/Version")
#configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Version.in" "${OSGQT_VERSION_HEADER}")
#list(APPEND lib_hdrs "${OSGQT_VERSION_HEADER}")
find_package(OpenSceneGraph REQUIRED osg osgDB osgGA osgText osgUtil osgViewer osgWidget OpenThreads)
find_package(Qt5 REQUIRED COMPONENTS Widgets Core OpenGL)
QT5_WRAP_CPP(SOURCES_H_MOC ${SOURCES_H} OPTIONS "-fosgQt/QGraphicsViewAdapter" )
list(APPEND lib_libs Qt5::Core Qt5::Widgets Qt5::OpenGL ${OPENSCENEGRAPH_LIBRARIES})
include_directories(${OSG_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DOSGQT_LIBRARY)
add_library(${PROJECT_NAME} SHARED ${lib_srcs} ${SOURCES_H_MOC})
target_link_libraries(${PROJECT_NAME} ${lib_libs})
install(FILES ${lib_hdrs} DESTINATION include/${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION lib/cmake FILE ${PROJECT_NAME}-config.cmake)